package com.cssy.yd.logic.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.byd.acegiext.domain.User;
import com.cssy.yd.logic.dao.LogicProSuggestItemDAO;
import com.cssy.yd.logic.dao.LogicSoDAO;
import com.cssy.yd.logic.dao.LogicSoItemDAO;
import com.cssy.yd.logic.dao.LogicSoWarefreezeDAO;
import com.cssy.yd.logic.dao.LogicSoWarefreezeItemDAO;
import com.cssy.yd.logic.dao.LogicSoWarefreezedealDAO;
import com.cssy.yd.logic.dao.LogicSoWarefreezedealItemDAO;
import com.cssy.yd.logic.dao.LogicSoWareunfreezeDAO;
import com.cssy.yd.logic.entity.LogicProSuggestItemDO;
import com.cssy.yd.logic.entity.LogicSoDO;
import com.cssy.yd.logic.entity.LogicSoItemDO;
import com.cssy.yd.logic.entity.LogicSoWarefreezeDO;
import com.cssy.yd.logic.entity.LogicSoWarefreezeItemDO;
import com.cssy.yd.logic.entity.LogicSoWarefreezedealDO;
import com.cssy.yd.logic.entity.LogicSoWarefreezedealItemDO;
import com.cssy.yd.logic.entity.LogicSoWareunfreezeDO;
import com.cssy.yd.logic.entity.LogicWhAffDO;
import com.cssy.yd.logic.service.ILogicSoService;
import com.cssy.yd.logic.service.ILogicWhAffStockService;
import com.cssy.yd.logic.util.MathUtil;
import com.cssy.yd.logic.util.logic.LogicSoBeanUtil;
import com.plat.exception.SyBaseException;
import com.plat.helper.SearchCondition;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;
import com.plat.util.DateUtils;
import com.plat.util.GlobalResLoader;
import com.plat.util.IDCodeTypeUtil;
import com.plat.util.SessionUtil;
import com.yuendong.sy.exception.SyCodeException;
import com.yuendong.sy.po.code.SyCode;
import com.yuendong.sy.service.code.SyCodeType;
import com.yuendong.sy.service.code.impl.SyCodeService;
/**
 * 销售订单业务方法
 * @modify huang.xuming [2013-7-9]
 *
 */
@Service("logicSoService")
public class LogicSoServiceImpl implements ILogicSoService {
	private static final Logger logger = Logger.getLogger(LogicSoServiceImpl.class);
	@Resource(name = "logicSoDAO")
	private LogicSoDAO logicSoDAO;
	
	@Resource(name = "logicSoItemDAO")
	private LogicSoItemDAO  logicSoItemDAO;
	
	@Resource(name = "logicSoWarefreezedealDAO")
	private LogicSoWarefreezedealDAO logicSoWarefreezedealDAO;
	@Resource(name = "logicSoWarefreezedealItemDAO")
	private LogicSoWarefreezedealItemDAO logicSoWarefreezedealItemDAO;
	
	@Resource(name = "logicSoWarefreezeDAO")
	private LogicSoWarefreezeDAO logicSoWarefreezeDAO;
	@Resource(name = "logicSoWarefreezeItemDAO")
	private LogicSoWarefreezeItemDAO logicSoWarefreezeItemDAO;
	
	@Resource(name = "logicSoWareunfreezeDAO")
	private LogicSoWareunfreezeDAO logicSoWareunfreezeDAO;
	
	@Resource(name = "logicProSuggestItemDAO")
	private LogicProSuggestItemDAO logicProSuggestItemDAO;
	
	@Resource(name = "logicWhAffStockService")
	private ILogicWhAffStockService logicWhAffStockService;
	
	@Resource(name = "syCodeService")
	private SyCodeService syCodeService;
	
	@Override
	public SearchResult findListByExample(SearchConditions scs)
			throws SyBaseException {
		SearchResult rs=new SearchResult(scs);
		List<LogicSoDO>  list=logicSoDAO.find(scs);
		rs.setRecordCount(logicSoDAO.count(scs));
		rs.setResults(list);
		return rs;
	}

	@Override
	public Integer delete(String id, User user) throws SyBaseException {
		logicSoDAO.deleteLogicSoDOByPrimaryKey(id);
		return null;
	}

	@Override
	public Integer update(LogicSoDO t, User user) throws SyBaseException {
		t.setDuuser(user.getName());
		t.setDutime(new Date());
		logicSoDAO.updateLogicSoDO(t);
		return null;
	}

	@Override
	public LogicSoDO save(LogicSoDO sodo, User user) throws SyBaseException {
		sodo.setDcruser(user.getName());
		sodo.setDctime(new Date());
		logicSoDAO.insertLogicSoDO(sodo);
		return sodo;
	}

	@Override
	public LogicSoDO findListById(String id) throws SyBaseException {
		return logicSoDAO.findLogicSoDOByPrimaryKey(id);
	}

	@Override
	public void soSave(HttpServletRequest request, LogicSoDO curAP)
			throws SyBaseException {
		try {
			String itemdata = request.getParameter("itemdata");
			List<LogicSoItemDO> soItemlist = JSONArray.parseArray(itemdata,
					LogicSoItemDO.class);
			
			/*
			 * 获取操作
			 * 0为保存(草稿状态)
			 * 1为提交(待审核状态)
			 * 2为二级审核(提交二级审核)
			 * 3为三级审核(提交三级审核)
			 * 4为二级结案(提交二级结案)
			 * 5为三级结案(提交三级结案)
			 * 6为二级驳回到草稿
			 * 7为三级驳回到草稿
			 * 8为拟稿人取消订单
			 * 
			 * -1部分出库强制完结
			 */
			String paramflag = request.getParameter("paramflag");
			int iToFlag = -1;
			iToFlag = Integer.parseInt(paramflag);
			curAP.setBillstatus(Integer.parseInt(paramflag));
			
			User user = SessionUtil.getUser(request);
			Date curDate = new Date();
			
			
			if (StringUtils.isBlank(curAP.getId())) {
				/* 新增  设置状态billstatus= 0*/
				String id = IDCodeTypeUtil.getId();
				curAP.setId(id);
				curAP.setDctime(curDate);
				curAP.setDcruser(user.getName());
				
				curAP.setLister(user.getName());
				curAP.setListerName(user.getRealName());
				
				curAP.setWareStatus(0);//订单的出库状态
				curAP.setFrozenStatus(0);//订单库存的冻结状态
				
//				curAP.setNo(BillCode.billcode.code(syCodeService.getCode(SyCodeType.DATE_CODE,
//						curAP.getCliNo(), curAP.getCliNo()), curAP.getCliNo()+DateUtils.dateToString(new Date(), "yyyyMMdd")));
				curAP.setNo(syCodeService.getCode("SP","SP",SyCode.DATE_YYMM,5));
				
				//日期转换处理
				String receipDate = request.getParameter("receipDate");
				if(StringUtils.isNotBlank(receipDate)){
					curAP.setReceipDate(DateUtils.stringToDate(receipDate));
				}
				String balanceDate = request.getParameter("balanceDate");
				if(StringUtils.isNotBlank(balanceDate)){
					curAP.setBalanceDate(DateUtils.stringToDate(balanceDate));
				}
				String deliveryDate = request.getParameter("deliveryDate");
				if(StringUtils.isNotBlank(deliveryDate)){
					curAP.setDeliveryDate(DateUtils.stringToDate(deliveryDate));
				}
				
				logicSoDAO.insertLogicSoDO(curAP);
				
				curAP.setId(id);//添加上，否则插入之后ID为0
				saveOrUpdateItems(soItemlist, curAP);
				
//				for (LogicSoItemDO soItemDO : soItemlist) {
//					soItemDO.setSoId(id);
//					soItemDO.setId(IDCodeTypeUtil.getId());
//					logicSoItemDAO.insertLogicSoItemDO(soItemDO);
//				}
				
			} else if(iToFlag >= 0 && iToFlag <=8){
				/* 修改 */
				LogicSoDO bean=logicSoDAO.findLogicSoDOByPrimaryKey(curAP.getId());
				if(null == bean.getVersion() || !bean.getVersion().equals(curAP.getVersion())){
					throw new SyBaseException("版本号异常，请刷新后重新编辑");
				}
				
				int oldFlag = bean.getBillstatus();
				bean.setBillstatus(iToFlag);
				
				int result = 0;
				if(2==iToFlag ){//2为二级审核(提交二级审核)
					curAP.setBillstatus(bean.getBillstatus());
					
					curAP.setDctime(bean.getDctime());
					curAP.setDcruser(bean.getDcruser());
					
					curAP.setLister(user.getName());
					curAP.setListerName(user.getRealName());
					curAP.setDutime(curDate);
					curAP.setDuuser(user.getName());
					
					//日期转换处理
					String receipDate = request.getParameter("receipDate");
					if(StringUtils.isNotBlank(receipDate)){
						curAP.setReceipDate(DateUtils.stringToDate(receipDate));
					}
					String balanceDate = request.getParameter("balanceDate");
					if(StringUtils.isNotBlank(balanceDate)){
						curAP.setBalanceDate(DateUtils.stringToDate(balanceDate));
					}
					String deliveryDate = request.getParameter("deliveryDate");
					if(StringUtils.isNotBlank(deliveryDate)){
						curAP.setDeliveryDate(DateUtils.stringToDate(deliveryDate));
					}
					
					
					result =logicSoDAO.updateLogicSoDO(curAP);
					if(result==1){
						saveOrUpdateItems(soItemlist, curAP);
					}
				}else if(3==iToFlag ||4==iToFlag || 6==iToFlag){//3为三级审核(提交三级审核) ，二级结案(提交二级结案)，6为二级驳回到草稿
					bean.setAuditor(user.getName());//二级
					bean.setAuditorName(user.getRealName());
					result =logicSoDAO.updateLogicSoDO(bean);
				}else if(5==iToFlag || 7==iToFlag){//5为三级结案(提交三级结案) ，7为三级驳回到草稿
					//进行二级结案到三级驳回时，如果库存状态、冻结状态被改动，则不允许三级驳回
					if(4==oldFlag && 7==iToFlag 
							&& (0!=bean.getFrozenStatus()||0!=bean.getWareStatus())){
						throw new SyBaseException(bean.getNo()+"销售订单的冻结标记或者出库标记导致禁止二级结案的驳回");
					}
					bean.setApprover(user.getName());//二级
					bean.setApproverName(user.getRealName());
					result =logicSoDAO.updateLogicSoDO(bean);
					
					// 检查库存是否足够出库，如果不足则生成生产建议单
					checkCreateProSuggestBill(curAP, soItemlist);
					
				}else if(8==iToFlag){//8为取消订单 
					bean.setDutime(bean.getDctime());
					bean.setDuuser(bean.getDcruser());
					result =logicSoDAO.updateLogicSoDO(bean);
				}
				
				if(result==0){
					throw new SyBaseException("您修改的行数据发生改变，请重新点开查看");
				}
			} else if(-1 == iToFlag){
				LogicSoDO bean=logicSoDAO.findLogicSoDOByPrimaryKey(curAP.getId());
				if(null == bean.getVersion() || !bean.getVersion().equals(curAP.getVersion())){
					throw new SyBaseException("版本号异常，请刷新后重新编辑");
				}
				//部分出库强制完结
				if(4 != bean.getBillstatus() && 5 != bean.getBillstatus()){
					throw new SyBaseException(bean.getNo()+"销售订单的单据状态不能强制完结出库！");
				}
				
				if(0 == bean.getWareStatus()){
					bean.setWareStatus(4);//强制未出库完结状态
				}else if(1 == bean.getWareStatus()){
					bean.setWareStatus(3);//强制部分出库完结状态
				}else{
					throw new SyBaseException(bean.getNo()+"销售订单的出库状态不能强制完结出库！");
				}

				
				
				if(1 == bean.getFrozenStatus() || 2 == bean.getFrozenStatus()){
					bean.setFrozenStatus(4);
					
					unfreezenWh(bean,SessionUtil.getUser(request));
				}
									
				int result =logicSoDAO.updateLogicSoDO(bean);
				if(result==0){
					throw new SyBaseException("您修改的行数据发生改变，请重新点开查看");
				}
			}else{
				throw new SyBaseException("ParamFlag不合法："+iToFlag);
			}
			
		} catch (Exception e) {
			//e.printStackTrace();
			logger.error(e.getMessage(), e);
			throw new SyBaseException(GlobalResLoader.getOpfailed()
					+ e.getMessage());
		}
	}

	/**
	 * 单据的子项持久化
	 * @param soItemlist
	 * @param curAP
	 */
	private void saveOrUpdateItems(List<LogicSoItemDO> soItemlist ,LogicSoDO curAP){
		//删除本订单下的item
		if (null != curAP.getId()) {
			logicSoItemDAO.deleteBySoid(curAP.getId());
		}

		// 插入单据的item
		if (null != soItemlist) {
			for (LogicSoItemDO soItemDO : soItemlist) {
				// 对需要处理的item进行赋值
				soItemDO.setId(IDCodeTypeUtil.getId());
				soItemDO.setSoId(curAP.getId());
				soItemDO.setSoNo(curAP.getNo());
				soItemDO.setCliNo(curAP.getCliNo());
				soItemDO.setCliName(curAP.getCliName());

				logicSoItemDAO.insertLogicSoItemDO(soItemDO);
			}
		}
	}
	
	/**
	 * 释放订单的全部冻结库存
	 * @param soDo
	 */
	private void unfreezenWh(LogicSoDO soDo,User user){
		
		List<LogicSoItemDO> soItems = logicSoItemDAO.findItemListBysoId(soDo.getId());
		
		//完结的冻结申请单
		SearchConditions scs2 = new SearchConditions();
		scs2.addCondition("so_no", soDo.getNo(), SearchCondition.OP_EQUAL);
		scs2.addCondition("billstatus", "2", SearchCondition.OP_EQUAL);//完结的冻结处理单据
		scs2.addCondition("frozen_status", "0,1,2", SearchCondition.OP_IN);//冻结状态的单据
		List<LogicSoWarefreezeDO> swfList = logicSoWarefreezeDAO.find(scs2);
		if(null == swfList || swfList.size() == 0){
			//无冻结记录
			logger.info(soDo.getNo()+"销售订单无未处理完的冻结申请，直接完结出库");
			return ;
		}
		
		logger.info(soDo.getNo()+"销售订单有未处理完的冻结申请");
		for(LogicSoWarefreezeDO swfDo : swfList){
			//冻结申请item
			List<LogicSoWarefreezeItemDO> swfItems = logicSoWarefreezeItemDAO.findItemListBySoWareFreezeId(swfDo.getId());
			
			//相应的冻结处理单--可能多个
			SearchConditions scs = new SearchConditions();
			scs.addCondition("sowarefreeze_no", swfDo.getNo(), SearchCondition.OP_EQUAL);
			scs.addCondition("billstatus", "2", SearchCondition.OP_EQUAL);//完结的冻结处理单据
			scs.addCondition("unfrozen_status", "0,1", SearchCondition.OP_IN);//冻结状态的单据
			List<LogicSoWarefreezedealDO> loWarefreezedealDOList = logicSoWarefreezedealDAO.find(scs);
			
			if(null != loWarefreezedealDOList && loWarefreezedealDOList.size() > 0){
				for(LogicSoWarefreezedealDO cwfd : loWarefreezedealDOList){
					//冻结处理item
					List<LogicSoWarefreezedealItemDO> swfdItems = logicSoWarefreezedealItemDAO.findItemListByswfdId(cwfd.getId());
					for (LogicSoWarefreezedealItemDO swfdItem : swfdItems) {
						double curJdBQty =  LogicSoBeanUtil.getInstance().calcFreezeDealItemCanUnfreezeBQty(swfdItem);
						double curJdQty = MathUtil.mathUtil.divide(curJdBQty,swfdItem.getProdUnitConvert());

						swfdItem.setDjjdBQuantity(swfdItem.getDjjdBQuantity() + curJdBQty);
						swfdItem.setDjjdQuantity(swfdItem.getDjjdQuantity() + curJdQty);
						// 冻结处理item持久化
						logicSoWarefreezedealItemDAO.updateLogicSoWarefreezedealItemDO(swfdItem);
						
						//冻结申请item和冻结处理item匹配的产品，相应释放冻结数量
						for(LogicSoWarefreezeItemDO swfItem: swfItems){
							
							if(LogicSoBeanUtil.getInstance().isSameMaterial(swfItem, swfdItem)){
								
								swfItem.setSjdjJdBQty(swfItem.getSjdjJdBQty()+curJdBQty);
								swfItem.setSjdjJdQty(swfItem.getSjdjJdQty()+curJdQty);
//								logicSoWarefreezeItemDAO.updateLogicSoWarefreezeItemDO(swfItem);
							}
						}
						
						//订单item匹配，相应释放冻结数量
						for(LogicSoItemDO soItem: soItems){
							if(LogicSoBeanUtil.getInstance().isSameMaterial(soItem, swfdItem)){
								soItem.setFrozenBQuantity(soItem.getFrozenBQuantity()-curJdBQty);
								soItem.setFrozenQuantity(soItem.getFrozenQuantity()-curJdQty);
							}
						}
						
						//解冻库存
						unfreezeWhAff(soDo, cwfd, swfdItem, user, curJdQty, curJdBQty);
					}
					//冻结处理状态修改
					cwfd.setUnfrozenStatus(2);//全部解冻
					logicSoWarefreezedealDAO.updateLogicSoWarefreezedealDO(cwfd);
				}
			}
			
			
			//冻结申请item完全解冻检查
			for(LogicSoWarefreezeItemDO swfItem: swfItems){
				if(0 != LogicSoBeanUtil.getInstance().calcFreezeItemCanUnfreezeBQty(swfItem)){
					throw new SyBaseException(swfDo.getNo()+"销售冻结申请单的"+swfItem.getProdNo()+"产品自动解冻数量不合法  "+LogicSoBeanUtil.getInstance().calcFreezeItemCanUnfreezeBQty(swfItem));
				}
				logicSoWarefreezeItemDAO.updateLogicSoWarefreezeItemDO(swfItem);
			}
			
			swfDo.setFrozenStatus(4);//全部解冻
			logicSoWarefreezeDAO.updateLogicSoWarefreezeDO(swfDo);
			
		}
		
		//销售订单item完全解冻检查
		for(LogicSoItemDO soItem: soItems){
			if(0 != soItem.getFrozenBQuantity()){
				throw new SyBaseException(soDo.getNo()+"销售订单的"+soItem.getProdNo()+"产品自动解冻数量不合法  "+soItem.getFrozenBQuantity());
			}
			logicSoItemDAO.updateLogicSoItemDO(soItem);
		}
		
		
		/* 未完结的冻结申请和处理单据处理--设为取消 */
		//冻结申请单据
		SearchConditions scs3 = new SearchConditions();
		scs3.addCondition("so_no", soDo.getNo(), SearchCondition.OP_EQUAL);
		scs3.addCondition("billstatus", "0,1,3", SearchCondition.OP_IN);//未完结的冻结处理单据
//		scs3.addCondition("frozen_status", "0,1,2", SearchCondition.OP_IN);//冻结状态的单据
		List<LogicSoWarefreezeDO> swfList2 = logicSoWarefreezeDAO.find(scs3);
		if(null != swfList2 && swfList2.size() > 0){
			for(LogicSoWarefreezeDO swf : swfList2){
				swf.setBillstatus(4);//设为取消状态
				logicSoWarefreezeDAO.updateLogicSoWarefreezeDO(swf);
				logger.info(swf.getNo()+"销售冻结申请单因强制订单完结而取消");
			}
		}
		
		//冻结处理单据
		SearchConditions scs4 = new SearchConditions();
		scs4.addCondition("so_no", soDo.getNo(), SearchCondition.OP_EQUAL);
		scs4.addCondition("billstatus", "0,1,3", SearchCondition.OP_IN);
		List<LogicSoWarefreezedealDO> swfdList2 = logicSoWarefreezedealDAO.find(scs4);
		if(null != swfdList2 && swfdList2.size() > 0){
			for(LogicSoWarefreezedealDO swfd : swfdList2){
				swfd.setBillstatus(4);//设为取消状态
				logicSoWarefreezedealDAO.updateLogicSoWarefreezedealDO(swfd);
				logger.info(swfd.getNo()+"销售冻结处理单因强制订单完结而取消");
			}
		}
		
		//冻结解冻单据  20131007
		SearchConditions scs5 = new SearchConditions();
		scs5.addCondition("so_no", soDo.getNo(), SearchCondition.OP_EQUAL);
		scs5.addCondition("billstatus", "0,1,3", SearchCondition.OP_IN);
		List<LogicSoWareunfreezeDO> swufList2 = logicSoWareunfreezeDAO.find(scs5);
		if(null != swufList2 && swufList2.size() > 0){
			for(LogicSoWareunfreezeDO swuf : swufList2){
				swuf.setBillstatus(4);//设为取消状态
				logicSoWareunfreezeDAO.updateLogicSoWareunfreezeDO(swuf);
				logger.info(swuf.getNo()+"销售解冻单因强制订单完结而取消");
			}
		}
		
	}
	
	/**
	 * 库存冻结--可用库存减少，冻结库存添加
	 * @param soDo
	 * @param sowfd
	 * @param sowfdItem
	 * @param user
	 * @param quantity
	 * @param jquantity
	 */
	private void unfreezeWhAff(LogicSoDO soDo, LogicSoWarefreezedealDO sowfd,LogicSoWarefreezedealItemDO sowfdItem,User user,double quantity,double jquantity) throws SyBaseException{
		
		LogicWhAffDO lwhaff = new LogicWhAffDO();
		lwhaff.setBillCode(soDo.getNo());
		lwhaff.setBillType("SJ");// 设置为销售冻结处理编码的头字符，供报表使用
		lwhaff.setWhCode(sowfd.getWhcode());
		lwhaff.setWhname(sowfd.getWhname());
		lwhaff.setBatch(sowfdItem.getProdBatch());
		lwhaff.setUnit(sowfdItem.getProdUnit());
		lwhaff.setJunit(sowfdItem.getProdBUnit());
		if(null != sowfdItem.getProdPrice()){
			lwhaff.setPrice(Double.valueOf(sowfdItem.getProdPrice().toString()));// ?
		}
		lwhaff.setCode(sowfdItem.getProdNo());
		lwhaff.setName(sowfdItem.getProdName());
		lwhaff.setSpec(sowfdItem.getProdSpecDesc());
		lwhaff.setBrand(sowfdItem.getProdModel());
		lwhaff.setHubCode(sowfdItem.getHubcode());
		lwhaff.setHubName(sowfdItem.getHubname());
		lwhaff.setStatus(sowfdItem.getStatus());// 冻结仓库
		/*可用库存添加*/
		lwhaff.setQuantity(quantity);
		lwhaff.setJquantity(jquantity);
		logicWhAffStockService.updateWhAffstockQuantity(lwhaff,user,false);
		
		
		/*冻结库存减少*/
		lwhaff.setStatus("4");// 冻结仓库
		lwhaff.setQuantity(-quantity);
		lwhaff.setJquantity(-jquantity);
		logicWhAffStockService.updateWhAffstockQuantity(lwhaff,user,false);
	}
	
	/**
	 * 检查并生成生产建议单 -- 临时
	 * @param soDo
	 * @param soItemlist
	 * @throws SyCodeException 
	 */
	private void checkCreateProSuggestBill(LogicSoDO soDo ,List<LogicSoItemDO> soItemlist ) throws SyCodeException{
		for(LogicSoItemDO soItem : soItemlist){
			//指定等级物料的库存数量
			double whQty = logicWhAffStockService.getSumQuantityByMaInfoAndStatus(soItem.getProdNo(), soItem.getStatus());
			double needQty = soItem.getProdBQuantity() - whQty;
			if(needQty > 0){
				
				//创建制定数量的生产建议单
				LogicProSuggestItemDO proSuggestItem = new LogicProSuggestItemDO();
				proSuggestItem.setId(IDCodeTypeUtil.getId());
				proSuggestItem.setNo(syCodeService.getCode("PS","PS",SyCode.DATE_YYMM,5));
				proSuggestItem.setSourceBillType("SP");
				proSuggestItem.setSourceBliiNo(soDo.getNo());
				proSuggestItem.setStatus(soItem.getStatus());
				proSuggestItem.setMaterialsid(soItem.getMaterialsid());
				proSuggestItem.setCode(soItem.getProdNo());
				proSuggestItem.setBacth(soItem.getProdBatch());
				proSuggestItem.setName(soItem.getProdName());
				proSuggestItem.setSpec(soItem.getProdSpecDesc());
				proSuggestItem.setUnit(soItem.getProdBUnit());
				proSuggestItem.setQuantity(needQty);
				proSuggestItem.setJunit(soItem.getProdBUnit());
				proSuggestItem.setJquantity(needQty);
				proSuggestItem.setDctime(new Date());
				proSuggestItem.setBillStatus(1);
				logicProSuggestItemDAO.insertLogicProSuggestItemDO(proSuggestItem);
			}
		}
	}

	@Override
	public Integer deleteBizRemoved(String id) throws SyBaseException {
		// TODO Auto-generated method stub
		return null;
	}
}
